local skynet = require "skynet.manager"

local max_client = tonumber(skynet.getenv "max_client")
local server_id = tonumber(skynet.getenv "server_id")
local watchdog_port = tonumber(skynet.getenv "listen_port")
local server_config = dofile(skynet.getenv("server_config"))
local server_name = skynet.getenv "server_name"


skynet.start(function()
	skynet.error("Server start")
	skynet.uniqueservice("pbloader")
	--skynet.uniqueservice("conf_loader")

	if not skynet.getenv "daemon" and server_config.no_cotainer then
		local console = skynet.newservice("console")
	end
	local debug_listen_ip = "127.0.0.1"
	if not server_config.no_cotainer then
		debug_listen_ip = "0.0.0.0"
	end
	skynet.newservice("debug_console",debug_listen_ip, server_config.debug_port)

	local proxy_conn = skynet.newservice('proxy_conn')
	skynet.call(proxy_conn,'lua','start')

	local kafka_queue = skynet.newservice('kafka_queue')
	skynet.name('.kafka_queue',kafka_queue)

	-- local test_kafka_queue = skynet.newservice('test_kafka_queue')

	local reload_service = skynet.uniqueservice('reload_service')
	skynet.name('.reload_service',reload_service)
	skynet.call(reload_service,'lua','pull_conf_data')

	-- local webclient = skynet.uniqueservice("webclient")
 	-- skynet.name('webclient', webclient)

	local table_mgr = skynet.uniqueservice('table_mgr')
	skynet.name('.table_mgr',table_mgr)

	local msg_handler = skynet.newservice('msg_handler')
	skynet.name('.msg_handler',msg_handler)
	skynet.call(msg_handler,'lua','start')

	-- local user_playing_handler = skynet.newservice('user_playing_handler')
	-- skynet.name('.user_playing_handler', user_playing_handler)
	-- skynet.call(user_playing_handler,'lua','start')
	local cards_library = skynet.newservice('cards_library_service')
	skynet.name('.cards_library', cards_library)

	local ddz_cards_library = skynet.newservice('ddz_cards_library')
	skynet.name('.ddz_cards_library', ddz_cards_library)

	local shapedata = skynet.newservice('shapedata')
	skynet.name('.shapedata',shapedata)
	skynet.call(shapedata,'lua','start')

	if server_config.debug then
		skynet.uniqueservice('cache_data')
	end
dbglog("__33333333333______data____________",game_session,uid)
	
	skynet.exit()
end)

